<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <!--如果是IE 就以标准渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <!-- 视窗——————响应式布局 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

    <!--当前页面的三要素-->
    <title>运维系统</title>
    <meta name="description" content="聚能优电" />
    <meta http-equiv="keywords" content="聚能优电" />
    <script type="text/javascript" src="./js/verify.js"></script>
    <script type="text/javascript" src="./js/common/commonfuntion.js"></script>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="./css/common/common.css" />
    <link rel="stylesheet" type="text/css" href="./css/jquery-accordion-menu.css" />
    <link rel="stylesheet" type="text/css" href="./css/mainmonitor_sz.css" />

</head>

<body>
    <div id="container" class="mainmonitor_sz">
        <div class="mainmonitor_sz_01">
            <!--主屏内容-->
            <div class="mainmonitor_sz_screen">
                <div class="m_title">
                    <a href="JavaScript:history.go(-1);" class="back">
                        <img src="./images/back.svg" alt="" />
                    </a>
                    <span class="tit" id="projectNameCN"></span>
                </div>

                <div class="m_content">
                    <header class="tabHead">
                        <span class="active" style="width:25%"><i>项目状态</i></span>
                        <span style="width:25%"><i>一次系统图</i></span>
                        <span style="width:25%;margin-left:20px;"><i>设置</i></span>
                    </header>
                    <article class="khfxWarp khfxWarpaa">
                        <div class="khfxPane xmzt khfxPaneaa">
                            <div class="zt2 ztdetail firstdetail">
                                <div class="tit_tit">
                                    <img src="./images/titicon.svg" alt="" />
                                    <span>柴油机</span>
                                </div>
                                <ul>
                                    <li>
                                        <p>总发电量</p>
                                        <div class="ztdiv">
                                            <span id="posKw">0</span><span>kWh</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>总功率</p>
                                        <div class="ztdiv">
                                            <span id="totalPower">0</span><span>kW</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>功率因数</p>
                                        <div class="ztdiv">
                                            <span id="pf">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>油耗</p>
                                        <div class="ztdiv">
                                            <span id="oilAcc">0</span><span>L/kWh</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>电流超前/滞后</p>
                                        <div class="ztdiv">
                                            <span id="laglead">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>燃油累积量</p>
                                        <div class="ztdiv">
                                            <span id="accFlow">0</span><span>m³</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>实时流量</p>
                                        <div class="ztdiv">
                                            <span id="realFlow">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>涡轮频率</p>
                                        <div class="ztdiv">
                                            <span id="realFreq">0</span><span>Hz</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>通讯状态</p>
                                        <div class="ztdiv">
                                            <span id="comFault">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>发电机转速</p>
                                        <div class="ztdiv">
                                            <span id="engine_speed">0</span><span>rpm</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>发电机停止状态</p>
                                        <div class="ztdiv">
                                            <span id="stopStatus">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>发电机合闸状态</p>
                                        <div class="ztdiv">
                                            <span id="switchStatus">0</span><span></span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>发电机手动模式</p>
                                        <div class="ztdiv">
                                            <span id="handModle">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>发电机机组有效状态</p>
                                        <div class="ztdiv">
                                            <span id="eqActStatus">0</span><span></span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            <div class="zt2 ztdetail" style="margin-top: 0.3rem;">
                                <div class="tit_tit">
                                    <img src="./images/titicon.svg" alt="" />
                                    <span>储能变流器</span>
                                </div>

                                <ul>
                                    <li>
                                        <p>功率</p>
                                        <div class="ztdiv">
                                            <span id="pcsWatt">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>当前防逆流值</p>
                                        <div class="ztdiv">
                                            <span id="backFlow">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>运行模式</p>
                                        <div class="ztdiv">
                                            <span id="runMode">0</span><span></span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            <div class="zt2 ztdetail" style="margin-top: 0.3rem;">
                                <div class="tit_tit">
                                    <img src="./images/titicon.svg" alt="" />
                                    <span>EMS</span>
                                </div>

                                <ul>
                                    <li>
                                        <p>电网电压</p>
                                        <div class="ztdiv">
                                            <span id="gridAVolt">0</span><span>V</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>电网功率</p>
                                        <div class="ztdiv">
                                            <span id="toalWatt">0</span><span>kW</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>负载功率</p>
                                        <div class="ztdiv">
                                            <span id="loadPower">0</span><span>kW</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>内部温度</p>
                                        <div class="ztdiv">
                                            <span id="temperature">0</span><span>℃</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                            <div class="zt2 ztdetail" style="margin-top: 0.3rem;">
                                <div class="tit_tit">
                                    <img src="./images/titicon.svg" alt="" />
                                    <span>储能电池</span>
                                </div>

                                <ul>
                                    <li>
                                        <p>电池簇1充电限流值</p>
                                        <div class="ztdiv">
                                            <span id="chargeCurrlimit1">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>电池簇2充电限流值</p>
                                        <div class="ztdiv">
                                            <span id="chargeCurrlimit2">0</span><span></span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>电池簇3充电限流值</p>
                                        <div class="ztdiv">
                                            <span id="chargeCurrlimit3">0</span><span></span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>电池簇4充电限流值</p>
                                        <div class="ztdiv">
                                            <span id="chargeCurrlimit4">0</span><span></span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>电池簇1SOC</p>
                                        <div class="ztdiv">
                                            <span id="soc3">0</span><span>%</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>电池簇2SOC</p>
                                        <div class="ztdiv">
                                            <span id="soc4">0</span><span>%</span>
                                        </div>
                                    </li>
                                </ul>
                                <ul>
                                    <li>
                                        <p>电池簇3SOC</p>
                                        <div class="ztdiv">
                                            <span id="soc1">0</span><span>%</span>
                                        </div>
                                    </li>
                                    <li>
                                        <p>电池簇4SOC</p>
                                        <div class="ztdiv">
                                            <span id="soc2">0</span><span>%</span>
                                        </div>
                                    </li>
                                </ul>

                                <ul>
                                    <li>
                                        <p>电池簇最小SOC</p>
                                        <div class="ztdiv">
                                            <span id="allSocVal">0</span><span>%</span>
                                        </div>
                                    </li>
                                </ul>
                            </div>

                        </div>

                        <div class="khfxPane khfxPaneaa">
                            <div class="formbody">
                                <div class="layoutmap">
                                    <div id="dwonoff">
                                        <!-- 电网功率为正数，箭头方向向右 -->
                                        <!-- 电网功率为0，箭头静止 -->
                                        <!-- 电网功率为负数，箭头方向向左 -->
                                        <!-- <div id="grightline1" class="hp hpthin goright" style="left:8%; top:33%;  width:40%; z-index: 1;"></div> -->
                                    </div>

                                    <div id="fzonoff">
                                        <!-- 负载功率为正数，箭头方向向右 -->
                                        <!-- 负载功率为0，箭头静止 -->
                                        <!-- 负载功率为负数，箭头方向向左 -->
                                        <!-- <div id="grightline2" class="hp hpthin goright" style="left:47%; top:33%;  width:40%; z-index: 1;"></div> -->
                                    </div>

                                    <div id="cyjgl">
                                        <!-- 发电功率为正数，箭头向下 -->
                                        <!-- 发电功率为0，箭头静止 -->
                                        <!-- 发电功率为负数，箭头向上 -->
                                        <!-- <div id="gdownline13" class="vp vpthin godown"
                                            style="left:46%; top:10%;  height:20%;z-index: 1;"></div> -->
                                    </div>
                                    <div id="pcsgljt">

                                        <!-- pcs功率为正数，箭头向下 -->
                                        <!-- pcs功率为0，箭头静止 -->
                                        <!-- pcs功率为负数，箭头向上 -->
                                        <!-- <div id="gdownline12" class="vpdif vpthin gotop"
                                            style="left:46%; top:60%;  height:20%;z-index: 1;"></div>

                                        <div id="gdownline11" class="vp vpthin gotop"
                                            style="left:46%; top:37%;  height:20%;z-index: 1;"></div> -->
                                    </div>

                                    <div class="layoutimage bordernull" title="柴油机"
                                        style="left:40%; top:0%; width:13.5%;z-index: 2;">
                                        <img src="./images/chaiyoujib.svg" alt=""
                                            style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>
                                    <div class="infobox dianwang" style="left:34%; top:15%;z-index: 2;padding:0;">
                                        <div class="pcontent">
                                            <span class="ptitle">总发电量(kWh):</span>
                                            <span id="zfdl">0</span>
                                        </div>
                                        <div class="pcontent">
                                            <span class="ptitle">发电功率(kW):</span>
                                            <span id="fdgl">0</span>
                                        </div>
                                        <div class="pcontent">
                                            <span class="ptitle">油耗(L/kWh):</span>
                                            <span id="yh">0</span>
                                        </div>
                                    </div>

                                    <div class="layoutimage bordernull" title="电网"
                                        style="left:0%; top:24.5%; width:13.5%;z-index: 2;">
                                        <img src="./images/dianwangb.svg" alt=""
                                            style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>
                                    <div class="infobox dianwang" style="left:0%; top:39%;z-index: 2;padding:0;">
                                        <div class="pcontent">
                                            <span class="ptitle">电网电压(V):</span>
                                            <span id="dwdy">0</span>
                                        </div>
                                        <div class="pcontent">
                                            <span class="ptitle">电网功率(kW):</span>
                                            <span id="dwgl">0</span>
                                        </div>
                                        <!-- <div class="pcontent">
                                            <p class="ptitle">P(kW):</p>
                                            <div id="cyj_rp"></div>
                                        </div> -->
                                    </div>

                                    <div class="layoutimage bordernull" title="一级柜"
                                        style="left:40%; top:24.5%; width:13.5%;z-index: 2;">
                                        <img src="./images/yjgb.svg" alt=""
                                            style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>
                                    
                                    <div class="layoutimage bordernull" title="负载"
                                        style="left:86%; top:24.5%; width:13.5%;z-index: 2;">
                                        <img src="./images/fuzaib.svg" alt=""
                                            style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>
                                    <div class="infobox zsfuzai" style="left:76%; top:39%; z-index: 2;padding:0;">
                                        <div class="pcontent">
                                            <span class="ptitle">负载功率(kW):</span>
                                            <span id="fzgl">0</span>
                                        </div>
                                    </div>

                                    <div class="layoutimage bordernull" title="PCS"
                                        style="left:40%; top:48%; width:13.5%;z-index: 2;">
                                        <img src="./images/pcsb.svg" alt=""
                                            style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>
                                    <div class="infobox zspcs" style="left:34%; top:63%; z-index: 2;padding:0;">
                                        <div class="pcontent">
                                            <span class="ptitle">当前防逆流值:</span>
                                            <span id="dqfnlz">0</span>
                                        </div>
                                        <div class="pcontent">
                                            <span class="ptitle">PCS功率(kW):</span>
                                            <span id="pcsgl">0</span>
                                        </div>

                                        <div class="pcontent">
                                            <span>运行模式:</span>
                                            <span id="yxms">0</span>
                                        </div>
                                    </div>

                                    <div class="layoutimage bordernull" title="BMS"
                                        style="left:40%; top:74%; width:13.5%;z-index: 2;">
                                        <img src="./images/bmsb.svg" alt="" style="width:100%;position: absolute;left: 50%;top: 50%;transform: translate(-50%, -50%);" />
                                    </div>

                                </div>
                            </div>
                        </div>

                        <div class="khfxPane khfxPaneaa">
                            <div class="setting">
                                <!-- <p class="settit">手动模式设置</p> -->
                                <ul>
                                    <li>
                                        <p>系统容量</p>
                                        <span class="shownum" id="totalCap">0</span>
                                        <!-- <input type="text" placeholder="请输入"> -->
                                        <!-- <button valuename="ccvalue" valueitem="issetcc">设置</button> -->
                                    </li>
                                </ul>

                            </div>
                            <div class="setting">
                                <p class="settit">运行模式</p>
                                <ul>
                                    <li>
                                        <p><span class="littit">系统运行模式</span>
                                            <!-- <span class="num_rang">(10-<span class="max">100</span>)</span> -->
                                        </p>
                                        <span class="shownum" id="szyxms">0</span>
                                        <!-- <input type="text" placeholder="请输入"> -->
                                        <select name="" id="changeRun">
                                            <option value="0"></option>
                                            <option value="1">自动</option>
                                            <option value="2">手动</option>
                                            
                                        </select>
                                        <button valuename="runmodelvalue" valueitem="issetrunmodel"
                                            model="model">设置</button>
                                    </li>
                                </ul>

                            </div>
                            <div class="setting">
                                <p class="settit">自动模式</p>
                                <ul>
                                    <li>
                                        <p><span class="littit">市储防逆流值</span><span class="num_rang">(10-<span
                                                    class="max">100</span>)</span></p>
                                        <span class="shownum" id="backFlow1">0</span>
                                        <input type="text" placeholder="">
                                        <button valuename="scvalue" valueitem="issetsc">设置</button>
                                    </li>
                                    <li>
                                        <p><span class="littit">市柴储防逆流值</span><span class="num_rang">(10-<span
                                                    class="max">100</span>)</span></p>
                                        <span class="shownum" id="backFlow2">0</span>
                                        <input type="text" placeholder="">
                                        <button valuename="sccvalue" valueitem="issetscc">设置</button>
                                    </li>
                                    <li>
                                        <p><span class="littit">SOC下限值</span><span
                                                class="num_rang">(10-100)</span></p>
                                        <span class="shownum" id="socLow">0</span>
                                        <input type="text" placeholder="">
                                        <button valuename="socvalue" valueitem="issetsoc">设置</button>
                                    </li>
                                </ul>

                            </div>
                            <div class="setting">
                                <p class="settit">手动模式</p>
                                <ul>
                                    <li>
                                        <p><span class="littit">柴储防逆流值</span><span class="num_rang">(10-<span
                                                    class="max">100</span>)</span></p>
                                        <span class="shownum" id="backFlow3">0</span>
                                        <input type="text" placeholder="">
                                        <button valuename="ccvalue" valueitem="issetcc">设置</button>
                                    </li>
                                </ul>

                            </div>
                        </div>
                    </article>
                </div>
            </div>
        </div>
    </div>

    <script>
        (function (win, doc) {
            var docEl = doc.documentElement || document.body; //获取HTML标签

            var container = doc.getElementById("container"); //container元素
            //判断是移动端设备还是PC,移动 就采用'orientationchange',横竖屏事件，PC端就采用onresize，窗口改变时间
            var resize =
                "onorientationchange" in win ? "orientationchange" : "resize";

            function rem() {
                docEl.style.fontSize = 100 * (container.clientWidth / 750) + "px";
            }

            //监听'DOMContent事件:DOM加载完成执行,如果DOMContent事件，那么执行rem函数
            doc.addEventListener("DOMContentLoaded", rem, false);

            //win下监听resize事件,如果resize事件，那么执行rem函数
            win.addEventListener(resize, rem, false);
        })(window, document);
    </script>
    <!-- js -->
    <script type="text/javascript" src="./js/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="js/echarts.js"></script>
    <script type="text/javascript" src="./layer/layer.js"></script>
    <script>
        $(document).ready(function () {
            // var index = layer.load(0, {
            //     shade: [0.8, '#fff']
            // }); //0.1透明度的白色背景
            // var projectid = GetQueryString('projectid');
            // var linechartid = GetQueryString('linechartid');
            // var projectNameCN = GetQueryString('projectNameCN');
            $("#projectNameCN").html(' ');
            $("#projectNameCN").html('深中二公局S06标段');
            var num_index = 0;
            var maxrunModel = 0;
            $.ajax({
                type: "GET",
                dataType: "json",
                url: "http://112.74.169.99:21021/api/TokenAuth/GetTemporaryEMS",
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01" );
                    xhr.setRequestHeader("Authorization", accessToken);
                    xhr.setRequestHeader('.AspNetCore.Culture', 'zh-Hans');
                },
                success: function (res) {
                    var data = res.result;

                    if (data.length == 0) {
                        layer.open({
                            type: 1,
                            content: '<div>' + '通讯异常' +
                                '</div>',
                            btn: '确定',
                            btnAlign: 'c', //按钮居中
                            shade: 0, //不显示遮罩
                            yes: function () {
                                layer.closeAll();
                                // layer.close(index);
                            }
                        });
                    } else {
                        $("#posKw").html(data.posKw); // 发电机总发电量
                        $("#accFlow").html(data.accFlow); // 燃油累积量
                        $("#realFlow").html(data.realFlow); // 实时流量

                        $("#realFreq").html(data.realFreq); // 涡轮频率
                        if(data.comFault == 0){
                            data.comFault = '正常';
                        }else if(data.comFault == 1){
                            data.comFault = '故障';
                        }
                        $("#comFault").html(data.comFault); // 发电机通讯故障
                        $("#gridAVolt").html(data.gridAVolt); // 电网电压

                        $("#allSocVal").html(data.allSocVal); // 电池簇最小SOC


                        
                        $("#pcsWatt").html(data.pcsWatt); // PCS 功率
                        if(data.pcsWatt > 0){// 一次系统图箭头 PCS功率
                            $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin godown" style="left:46%; top:60%;  height:20%;z-index: 1;"></div>
                                                <div id="gdownline11" class="vp vpthin godown" style="left:46%; top:37%;  height:20%;z-index: 1;"></div>`);
                        }else if(data.pcsWatt < 0){
                            $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin gotop" style="left:46%; top:60%;  height:20%;z-index: 1;"></div>
                                                <div id="gdownline11" class="vp vpthin gotop" style="left:46%; top:37%;  height:20%;z-index: 1;"></div> `);
                        }else if(data.pcsWatt == 0){
                            $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin" style="left:46%; top:60%;  height:20%;z-index: 1;"></div>
                                                <div id="gdownline11" class="vp vpthin" style="left:46%; top:37%;  height:20%;z-index: 1;"></div>`);
                        }


                        $("#loadPower").html(data.loadPower); // 负载功率
                        if(data.loadPower >0){// 一次系统图箭头 负载
                            $("#fzonoff").html(`<div id="grightline2" class="hp hpthin goright"style="left:47%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }else if(data.loadPower < 0){
                            $("#fzonoff").html(`<div id="grightline2" class="hp hpthin goleft" style="left:47%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }else if(data.loadPower == 0){
                            $("#fzonoff").html(`<div id="grightline2" class="hp hpthin" style="left:47%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }

                        $("#toalWatt").html(data.toalWatt); // 电网功率
                        if(data.toalWatt > 0){// 一次系统图箭头 电网
                            $("#dwonoff").html(`<div id="grightline1" class="hp hpthin goright" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }else if(data.toalWatt < 0){
                            $("#dwonoff").html(`<div id="grightline1" class="hp hpthin goleft" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }else if(data.toalWatt == 0){
                            $("#dwonoff").html(`<div id="grightline1" class="hp hpthin" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                        }

                        $("#backFlow").html(data.backFlow); // 当前防逆流值
                        if (data.runMode == 1) {
                            data.runMode = '自动';
                        } else if (data.runMode == 2) {
                            data.runMode = '手动';
                        }
                        $("#runMode").html(data.runMode); // 运行模式

                        $("#temperature").html(data.temperature); // EMS内部温度
                        $("#engine_speed").html(data.engine_speed); // 发电机转速

                        $("#totalPower").html(data.totalPower); // 发电机总功率  // 柴油机的发电功率
                        if(data.totalPower > 0){ // 一次系统图箭头 柴油机
                            $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin godown" style="left:46%; top:10%;  height:20%;z-index: 1;"></div>`);
                        }else if(data.totalPower < 0){
                            $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin gotop" style="left:46%; top:10%;  height:20%;z-index: 1;"></div>`);
                        }else if(data.totalPower == 0){
                            $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin" style="left:46%; top:10%;  height:20%;z-index: 1;"></div>`);
                        }
                        

                        $("#oilAcc").html(data.oilAcc); // 油耗
                        $("#laglead").html(data.laglead); // 电流超前/滞后
                        $("#pf").html(data.pf); // 平均功率因数


                        $("#soc1").html(data.soc1); // 电池簇1SOC
                        $("#soc2").html(data.soc2); // 电池簇2SOC
                        $("#soc3").html(data.soc3); // 电池簇3SOC
                        $("#soc4").html(data.soc4); // 电池簇4SOC

                        $("#chargeCurrlimit1").html(data.chargeCurrlimit1); // 电池簇1充电限流值
                        $("#chargeCurrlimit2").html(data.chargeCurrlimit2); // 电池簇2充电限流值
                        $("#chargeCurrlimit3").html(data.chargeCurrlimit3); // 电池簇3充电限流值
                        $("#chargeCurrlimit4").html(data.chargeCurrlimit4); // 电池簇4充电限流值

                        if(data.stopStatus == 0){
                            data.stopStatus = "开启";
                        }else if(data.stopStatus == 1){
                            data.stopStatus = "停机";
                        }
                        $("#stopStatus").html(data.stopStatus); // 发电机停止状态

                        $("#handModle").html(data.handModle); // 发电机手动模式

                        if(data.switchStatus == 0){
                            data.switchStatus = "分闸";
                        }else if(data.switchStatus == 1){
                            data.switchStatus = "合闸";
                        }
                        $("#switchStatus").html(data.switchStatus); // 发电机合闸状态

                        $("#eqActStatus").html(data.eqActStatus); // 发电机机组有效状态


                        // 一次系统图
                        // 电网
                        $("#dwdy").html(data.gridAVolt);//电网电压
                        $("#dwgl").html(data.toalWatt);//电网功率

                        // 柴油机
                        $("#zfdl").html(data.posKw);//总发电量
                        $("#fdgl").html(data.totalPower);//发电功率
                        $("#yh").html(data.oilAcc);//油耗

                        // 负载
                        $("#fzgl").html(data.loadPower);//负载功率

                        // PCS
                        $("#dqfnlz").html(data.backFlow);//当前防逆流值
                        $("#pcsgl").html(data.pcsWatt);//PCS功率

                        $("#yxms").html(data.runMode);//运行模式

                        // 设置
                        maxrunModel = data.totalCap;
                        $("#totalCap").html(data.totalCap);//系统总容量
                        $("#szyxms").html(data.runMode);//系统运行模式
                        $("#backFlow1").html(data.backFlow1);//市储防逆流值
                        $("#backFlow2").html(data.backFlow2);//市柴储防逆流值
                        $("#socLow").html(data.socLow);//SOC下限值
                        $("#backFlow3").html(data.backFlow3);//柴储防逆流值


                        $(".max").each(function(a,b){
                            $(this).text(' ');
                            $(this).text(data.totalCap);
                        });
                    
                        setInterval(updateData,1000);
                    }

                },
                error: function (err) {
                    console.log("首次请求数据 请求失败");
                }
            });

            // tab选项卡切换
            $(".tabHead span").on("click", function () {
                var $this = $(this);
                var itemIndex = $this.index();
                $(this).addClass("active").siblings(".tabHead span").removeClass("active");
                $(".khfxPane").eq(itemIndex).show().siblings(".khfxPane").hide();
            });


            function updateData() { // 请求数据
                num_index++;
                var onoff = isPositiveNum(num_index / 15); //一分钟增加一次数据

                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "http://112.74.169.99:21021/api/TokenAuth/GetTemporaryEMS",
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("Accept", "application/json, text/javascript, */*; q=0.01");
                        xhr.setRequestHeader("Authorization", accessToken);
                        xhr.setRequestHeader('.AspNetCore.Culture', 'zh-Hans');
                    },
                    success: function (res) {
                        var data = res.result;

                        $("#posKw").html(data.posKw); // 发电机总发电量
                        $("#accFlow").html(data.accFlow); // 燃油累积量
                        $("#realFlow").html(data.realFlow); // 实时流量

                        $("#realFreq").html(data.realFreq); // 涡轮频率
                        if(data.comFault == 0){
                            data.comFault = '正常';
                        }else if(data.comFault == 1){
                            data.comFault = '故障';
                        }
                        $("#comFault").html(data.comFault); // 发电机通讯故障
                        $("#gridAVolt").html(data.gridAVolt); // 电网电压

                        $("#allSocVal").html(data.allSocVal); // 电池簇最小SOC

                        $("#pcsWatt").html(data.pcsWatt); // PCS 功率
                        if(num_index == 1){
                            if(data.pcsWatt > 0){// 一次系统图箭头 PCS功率
                                $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin godown" style="left:46%; top:60%; height:20%;z-index: 1;"></div>
                                                    <div id="gdownline11" class="vp vpthin godown" style="left:46%; top:37%; height:20%;z-index: 1;"></div>`);
                            }else if(data.pcsWatt < 0){
                                $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin gotop" style="left:46%; top:60%; height:20%;z-index: 1;"></div>
                                                    <div id="gdownline11" class="vp vpthin gotop" style="left:46%; top:37%; height:20%;z-index: 1;"></div>`);
                            }else if(data.pcsWatt == 0){
                                $("#pcsgljt").html(`<div id="gdownline12" class="vpdif vpthin" style="left:46%; top:60%; height:20%;z-index: 1;"></div>
                                                    <div id="gdownline11" class="vp vpthin" style="left:46%; top:37%; height:20%;z-index: 1;"></div>`);
                            }
                        }

                        $("#loadPower").html(data.loadPower); // 负载功率
                        if(num_index == 1){
                            if(data.loadPower >0){// 一次系统图箭头 负载
                                $("#fzonoff").html(`<div id="grightline2" class="hp hpthin goright" style="left:47%; top:33%;  width:40%; z-index: 1;"></div>`);
                            }else if(data.loadPower < 0){
                                $("#fzonoff").html(`<div id="grightline2" class="hp hpthin goleft" style="left:47%; top:33%;  width:40%; z-index: 1;"> </div>`);
                            }else if(data.loadPower == 0){
                                $("#fzonoff").html(`<div id="grightline2" class="hp hpthin" style="left:47%; top:33%;  width:40%; z-index: 1;"> </div>`);
                            }
                        }

                        $("#toalWatt").html(data.toalWatt); // 电网功率
                        if(num_index == 1){
                            if(data.toalWatt > 0){// 一次系统图箭头 电网
                                $("#dwonoff").html(`<div id="grightline1" class="hp hpthin goright" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                            }else if(data.toalWatt < 0){
                                $("#dwonoff").html(`<div id="grightline1" class="hp hpthin goleft" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                            }else if(data.toalWatt == 0){
                                $("#dwonoff").html(`<div id="grightline1" class="hp hpthin" style="left:8%; top:33%;  width:40%; z-index: 1;"></div>`);
                            }
                        }

                        $("#backFlow").html(data.backFlow); // 当前防逆流值
                        if (data.runMode == 1) {
                            data.runMode = '自动';
                        } else if (data.runMode == 2) {
                            data.runMode = '手动';
                        }
                        $("#runMode").html(data.runMode); // 运行模式

                        $("#temperature").html(data.temperature); // EMS内部温度
                        $("#engine_speed").html(data.engine_speed); // 发电机转速

                        $("#totalPower").html(data.totalPower); // 发电机总功率 // 柴油机的发电功率
                        if(num_index == 1){
                            if(data.totalPower > 0){ // 一次系统图箭头 柴油机
                                $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin godown" style="left:46%; top:10%; height:20%;z-index: 1;"></div>`);
                            }else if(data.totalPower < 0){
                                $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin gotop" style="left:46%; top:10%; height:20%;z-index: 1;"></div>`);
                            }else if(data.totalPower == 0){
                                $("#cyjgl").html(`<div id="gdownline13" class="vp vpthin" style="left:46%; top:10%; height:20%;z-index: 1;"></div>`);
                            }
                        }

                        $("#oilAcc").html(data.oilAcc); // 油耗
                        $("#laglead").html(data.laglead); // 电流超前/滞后
                        $("#pf").html(data.pf); // 平均功率因数


                        $("#powrDownNum").html(data.powrDownNum); // 关机次数
                        $("#updateNum").html(data.updateNum); // 更新次数

                        $("#soc1").html(data.soc1); // 电池簇1SOC
                        $("#soc2").html(data.soc2); // 电池簇2SOC
                        $("#soc3").html(data.soc3); // 电池簇3SOC
                        $("#soc4").html(data.soc4); // 电池簇4SOC

                        $("#chargeCurrlimit1").html(data.chargeCurrlimit1); // 电池簇1充电限流值
                        $("#chargeCurrlimit2").html(data.chargeCurrlimit2); // 电池簇2充电限流值
                        $("#chargeCurrlimit3").html(data.chargeCurrlimit3); // 电池簇3充电限流值
                        $("#chargeCurrlimit4").html(data.chargeCurrlimit4); // 电池簇4充电限流值

                        if(data.stopStatus == 0){
                            data.stopStatus = "开启";
                        }else if(data.stopStatus == 1){
                            data.stopStatus = "停机";
                        }
                        $("#stopStatus").html(data.stopStatus); // 发电机停止状态

                        $("#handModle").html(data.handModle); // 发电机手动模式

                        if(data.switchStatus == 0){
                            data.switchStatus = "分闸";
                        }else if(data.switchStatus == 1){
                            data.switchStatus = "合闸";
                        }
                        $("#switchStatus").html(data.switchStatus); // 发电机合闸状态

                        $("#eqActStatus").html(data.eqActStatus); // 发电机机组有效状态


                        // 一次系统图
                        // 电网
                        $("#dwdy").html(data.gridAVolt);//电网电压
                        $("#dwgl").html(data.toalWatt);//电网功率

                        // 柴油机
                        $("#zfdl").html(data.posKw);//总发电量
                        $("#fdgl").html(data.totalPower);//发电功率
                        $("#yh").html(data.oilAcc);//油耗

                        // 负载
                        $("#fzgl").html(data.loadPower);//负载功率
                        
                        // PCS
                        $("#dqfnlz").html(data.backFlow);//当前防逆流值
                        $("#pcsgl").html(data.pcsWatt);//PCS功率
                        
                        $("#yxms").html(data.runMode);//运行模式

                        // 设置
                        maxrunModel = data.totalCap;
                        $("#totalCap").html(data.totalCap);//系统容量
                        $("#szyxms").html(data.runMode);//系统运行模式
                        $("#backFlow1").html(data.backFlow1);//市储防逆流值
                        $("#backFlow2").html(data.backFlow2);//市柴储防逆流值
                        $("#socLow").html(data.socLow);//SOC下限值
                        $("#backFlow3").html(data.backFlow3);//柴储防逆流值

                        $(".max").each(function(a,b){
                            $(this).text(' ');
                            $(this).text(data.totalCap);
                        });
                    },
                    error: function (err) {
                        console.log("数据请求失败");
                    }
                });
            }

            // 判断是否为数字
            function isNumber(val) {
                if (val == "" || isNaN(val)) {
                    return false;
                } else {
                    return true;
                }
            }
            
            
            setTimeout(function(){
                console.log(maxrunModel);
            },3000);
            
            var abc = 100;
            // 设置页面的js
            $(".setting button").click(function(){
                var _this = this;
                var model = $(_this).attr('model');

                var value = $(_this).prev().val();
                var tit = $(_this).prev().prev().prev().find('.littit').text();

                var valuename = $(_this).attr('valuename');
                var valueitem = $(_this).attr('valueitem');
                var value_style = isNumber(value);

                if(value == ''){
                    layer.msg('请输入修改值', {
                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                    });
                }else{
                    if(!value_style){
                        layer.msg('请输入数字', {
                            time: 1000 //1秒关闭（如果不配置，默认是3秒）
                        },function(){
                            $(_this).prev().val(' ').focus();
                        });
                    }else{
                        if(model == "model"){
                            if(value == '0'){
                                layer.msg('请选择修改模式', {
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                });
                            }else {
                                layer.prompt({
                                    title: '输入密码-' + tit,
                                    formType: 1,
                                    yes:function(index, layero){
                                        var pass = layero.find(".layui-layer-input").val();
                                        if(pass == "nyy@nyy@2019"){
                                            layer.close(index);
                                            $.ajax({
                                                type: "GET",
                                                url:
                                                "http://112.74.169.99:21021/api/TokenAuth/SetDeviceValue?value=" + value + "&valuename=" + valuename + "&valueitem=" + valueitem,
                                                success: function (res) {
                                                    layer.msg('设置成功', {
                                                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                                    });
                                                    $(_this).prev().val('');
                                                },
                                                error: function (err) {
                                                    console.log(err);
                                                    layer.msg('设置失败', {
                                                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                                    });
                                                }
                                            })
                                        }else{
                                            layer.msg('请输入正确密码', {
                                                time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                            });
                                        }
                                    }
                                });

                            }
                            
                        }else if(model != "model"){
                            if(value > maxrunModel){
                                layer.msg('请输入范围内的值', {
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                },function(){
                                    $(_this).prev().val(' ').focus();
                                });
                            }else if(value < 10){
                                layer.msg('请输入范围内的值', {
                                    time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                },function(){
                                    $(_this).prev().val(' ').focus();
                                });
                            }else{
                                layer.prompt({
                                    title: '输入密码-' + tit,
                                    formType: 1,
                                    yes:function(index, layero){
                                        var pass = layero.find(".layui-layer-input").val();
                                        if(pass == "nyy@nyy@2019"){
                                            layer.close(index);
                                            $.ajax({
                                                type: "GET",
                                                url:
                                                "http://112.74.169.99:21021/api/TokenAuth/SetDeviceValue?value=" + value + "&valuename=" + valuename + "&valueitem=" + valueitem,
                                                success: function (res) {
                                                    layer.msg('设置成功', {
                                                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                                    });
                                                    $(_this).prev().val('');
                                                },
                                                error: function (err) {
                                                    console.log(err);
                                                    layer.msg('设置失败', {
                                                        time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                                    });
                                                }
                                            })
                                        }else{
                                            layer.msg('请输入正确密码', {
                                                time: 1000 //1秒关闭（如果不配置，默认是3秒）
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    }
                }
            });
        });
    </script>
</body>

</html>